package ute.mvc.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.validation.constraints.Size;

import org.hibernate.validator.constraints.NotEmpty;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity
public class QuestionPool implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = -7356146393387840010L;
	@Id
	@Column(length = 20)
	private String questionPoolId;
	
	@NotEmpty
	@Size(max=100)
	@Column(length = 100, nullable = false, unique = true)
	private String questionPoolName;
	
	@NotEmpty
	@Size(max=10000)
	@Column(length = 10000)
	private String description;

	@JsonIgnore
	@ManyToOne
	@JoinColumn(name = "lecturerId", nullable = false)
	private User lecturer;

	@JsonIgnore
	@ManyToOne
	@JoinColumn(name = "subjectId", nullable = false)
	private Subject subject;

	@JsonIgnore
	@OneToMany(mappedBy = "questionPool", fetch = FetchType.EAGER)
	private Collection<Question> listQuestion = new ArrayList<Question>();

	// Added by Vinh
	public Collection<Question> getListQuestion() {
		return listQuestion;
	}

	public void setListQuestion(Collection<Question> listQuestion) {
		this.listQuestion = listQuestion;
	}

	public User getLecturer() {
		return lecturer;
	}

	public void setLecturer(User lecturer) {
		this.lecturer = lecturer;
	}

	public String getQuestionPoolId() {
		return questionPoolId;
	}

	public void setQuestionPoolId(String questionPoolId) {
		this.questionPoolId = questionPoolId;
	}

	public Subject getSubject() {
		return subject;
	}

	public void setSubject(Subject subject) {
		this.subject = subject;
	}

	public String getQuestionPoolName() {
		return questionPoolName;
	}

	public void setQuestionPoolName(String questionPoolName) {
		this.questionPoolName = questionPoolName;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
}
